<?php

namespace app\index\controller;

use think\Controller;
use think\Request;
use app\index\model\Reply as ReplyModel;

class Reply extends Controller
{

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        if(!$request->isAjax()){
            $this->error('访问页面不存在');
        }

        $data = $request->post();
        $result = ReplyModel::createItem($data);
        if($result->status){
            $data = $result->data;
            $this->success($result->message);
        }else{
            $this->error($result->message);
        }
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete(Request $request, $id)
    {
        $param = $request->post();
        $result = ReplyModel::deleteItem($id, $param);
        if($result->status){
            $this->success($result->message);
        }else{
            $this->error($result->message);
        }
    }
}
